package com.smart.campus.school.service.impl;

import java.util.List;
import com.smart.campus.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smart.campus.school.mapper.MerchantMapper;
import com.smart.campus.school.domain.Merchant;
import com.smart.campus.school.service.IMerchantService;
import com.smart.campus.common.core.text.Convert;

/**
 * 商户Service业务层处理
 * 
 * @author Zhihe.Li
 * @date 2020-07-27
 */
@Service
public class MerchantServiceImpl implements IMerchantService 
{
    @Autowired
    private MerchantMapper merchantMapper;

    /**
     * 查询商户
     * 
     * @param id 商户ID
     * @return 商户
     */
    @Override
    public Merchant selectMerchantById(Long id)
    {
        return merchantMapper.selectMerchantById(id);
    }

    /**
     * 查询商户列表
     * 
     * @param merchant 商户
     * @return 商户
     */
    @Override
    public List<Merchant> selectMerchantList(Merchant merchant)
    {
        return merchantMapper.selectMerchantList(merchant);
    }

    /**
     * 新增商户
     * 
     * @param merchant 商户
     * @return 结果
     */
    @Override
    public int insertMerchant(Merchant merchant)
    {
        merchant.setCreateTime(DateUtils.getNowDate());
        return merchantMapper.insertMerchant(merchant);
    }

    /**
     * 修改商户
     * 
     * @param merchant 商户
     * @return 结果
     */
    @Override
    public int updateMerchant(Merchant merchant)
    {
        merchant.setUpdateTime(DateUtils.getNowDate());
        return merchantMapper.updateMerchant(merchant);
    }

    /**
     * 删除商户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMerchantByIds(String ids)
    {
        return merchantMapper.deleteMerchantByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商户信息
     * 
     * @param id 商户ID
     * @return 结果
     */
    @Override
    public int deleteMerchantById(Long id)
    {
        return merchantMapper.deleteMerchantById(id);
    }
}
